package com.open.demo.设计模式

class Robot private constructor(
    val code:String,
    val battery:String?,
    val height: Int?,
    val weight:Int?
) {

    class Builder(val code:String) {
        private var battery:String? = null
        private var height:Int? = null
        private var weight:Int? = null

        fun setBattery(battery: String):Builder {
            this.battery = battery
            return this
        }

        fun setHeight(height:Int):Builder {
            this.height = height
            return this
        }

        fun setWeight(weight: Int):Builder {
            this.weight = weight
            return this
        }

        fun build():Robot {
            return Robot(code,battery,height,weight)
        }

    }
}

class 构造者模式 {
}

fun main() {
    Robot.Builder("200").setBattery("").build()
}